<?php

use App\Http\Controllers\Api\AuthController;
use App\Http\Controllers\Api\CaptchaController;
use App\Http\Controllers\Api\CourseController;
use App\Http\Controllers\Api\HomeController;
use App\Http\Controllers\Api\SubjectController;
use App\Http\Controllers\Api\TraningController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Mews\Captcha\CaptchaController as CaptchaCaptchaController;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::namespace('api')->group(function () {
    // Route::middleware('auth:api')->group(function () {
    //     //用户信息
    //     Route::get('user', function (Request $request) {
    //         return $request->user();
    //     });
    // });
    Route::get('/home', [HomeController::class, 'index']);
    Route::prefix('course')->group(function () {
        Route::get('/', [CourseController::class, 'index']);
        Route::get('/dashboard', [CourseController::class, 'dashboard']);
        Route::get('/{id}', [CourseController::class, 'show']);
        Route::get('/subject', [SubjectController::class, 'index']);
    });
    Route::prefix('traning')->group(function () {
        Route::get('/', [TraningController::class, 'index']);
        Route::get('/dashboard', [TraningController::class, 'dashboard']);
        Route::get('/{id}', [TraningController::class, 'show']);
    });
    Route::post('captcha/image', [CaptchaController::class,'image']);
    Route::prefix('auth/')->group(function () {
        //用户注册
        Route::post('register', [AuthController::class, 'register']);
        Route::post('login', [AuthController::class, 'login']);
        Route::middleware('auth.jwt')->group(function () {
            //当前用户信息
            Route::get('info', [AuthController::class, 'info']);
        });
    });
});